home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
apl
/
gview120.lzh
/
gviewsrc.lzh
/
alloc.c
next >
Wrap
C/C++ Source or Header
|
1995-02-16
|
2KB
|
85 lines
/*
Copyright 1995 Ogasawara Hiroyuki(COR.)
*/
#include <corlib.h>
#include <sys_doslib.h>
#include "gview.h"
GVIEW *
GV_Alloc( h, v, color, fname, comment, len )
char *fname;
char *comment;
{
int psize= GV_PaletSize( color ),
fsize= strlen(fname)+1,
csize= comment ? strlen(comment)+1 : 1,
msize= sizeof(GVIEW)+ sizeof(short)*psize+ psize*3+
fsize+ csize;
GVIEW *gp;
msize= (msize+4) & 0xfffffffc;
if( !psize ){ /* 65536 */
if( (int)(gp= MALLOC( msize + h*v*2+len )) < 0 )
return NULL;
gp->buf= (void*)((char*)gp+ msize);
gp->palet= NULL;
gp->base_palet= NULL;
gp->fname= (void*)((char*)gp+sizeof(GVIEW));
}else{
if( (int)(gp= MALLOC( msize + h*v+len )) < 0 )
return NULL;
gp->buf= (void*)((char*)gp+ msize);
gp->palet= (void*)((char*)gp+sizeof(GVIEW));
gp->base_palet= (void*)((char*)gp->palet+sizeof(short)*psize);
gp->fname= (char*)gp->base_palet+ psize*3;
}
strcpy( gp->fname, fname );
gp->comment= gp->fname + fsize;
if( comment )
strcpy( gp->comment, comment );
else
*gp->comment= '\0';
gp->rh= gp->h= h;
gp->rv= gp->v= v;
gp->color= color;
gp->rx= gp->ry=
gp->flag= gp->info= 0;
gp->wp= NULL;
return gp;
#if 0
gp= malloc( sizeof(GVIEW) + sizeof(short)*psize + sizeof(int)*psize +
fsize + csize );
if( !gp )
return NULL;
if( !psize ){ /* 65536 */
gp->buf= MALLOC( h*v*2 );
gp->palet= NULL;
gp->base_palet= NULL;
gp->fname= (void*)((char*)gp+sizeof(GVIEW));
}else{
gp->buf= MALLOC( h*v );
gp->palet= (void*)((char*)gp+sizeof(GVIEW));
gp->base_palet= (void*)((char*)gp->palet+sizeof(short)*psize);
gp->fname= (char*)gp->base_palet+ sizeof(int)*psize;
}
if( (int)gp->buf < 0 ){
free( gp );
return NULL;
}
strcpy( gp->fname, fname );
gp->comment= gp->fname + fsize;
if( comment )
strcpy( gp->comment, comment );
else
*gp->comment= '\0';
gp->h= h;
gp->v= v;
gp->color= color;
gp->mode= gp->flag= gp->small_level= 0;
gp->wp= NULL;
return gp;
#endif
}